package com.web.dao;

import com.web.entity.MskPriceCount;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

/**
 * @author FDjavaone
 */
public interface MskPriceCountMapper {

    @Delete({
        "delete from t_msk_price_count",
        " where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into t_msk_price_count (price, create_time,",
        " modify_time)",
        " values (#{price,jdbcType=DECIMAL}, #{createTime,jdbcType=TIMESTAMP}, ",
        " #{modifyTime,jdbcType=TIMESTAMP})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)
    int insert(MskPriceCount record);

    @InsertProvider(type=MskPriceCountSqlProvider.class, method="insertSelective")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)
    int insertSelective(MskPriceCount record);


    @Select({
        "select",
        " id, price, create_time, modify_time",
        " from t_msk_price_count",
        " where id = #{id,jdbcType=BIGINT}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="price", property="price", jdbcType=JdbcType.DECIMAL),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="modify_time", property="modifyTime", jdbcType=JdbcType.TIMESTAMP)
    })
    MskPriceCount selectByPrimaryKey(Long id);


    @UpdateProvider(type=MskPriceCountSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(MskPriceCount record);

    @Update({
        "update t_msk_price_count",
        " set price = #{price,jdbcType=DECIMAL},",
          " create_time = #{createTime,jdbcType=TIMESTAMP},",
          " modify_time = #{modifyTime,jdbcType=TIMESTAMP}",
        " where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(MskPriceCount record);

    @Select({
            "select",
            " id, price, create_time, modify_time",
            " from t_msk_price_count",
            "  where id = (SELECT max(id) FROM t_msk_price_count)"
    })
    @Results({
            @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
            @Result(column="price", property="price", jdbcType=JdbcType.DECIMAL),
            @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="modify_time", property="modifyTime", jdbcType=JdbcType.TIMESTAMP)
    })
    MskPriceCount selectLastOne();

    @Select({
            "select",
            " id, price, create_time, modify_time",
            " from t_msk_price_count",
            " order by create_time desc limit 60"
    })
    @Results({
            @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
            @Result(column="price", property="price", jdbcType=JdbcType.DECIMAL),
            @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="modify_time", property="modifyTime", jdbcType=JdbcType.TIMESTAMP)
    })
    List<MskPriceCount> selectNewSixty();
}